package demo5;

import components.AutoGun;
import components.MousePosition;
import components.RotateTowardsMouse;
import components.ShipController;
import java2d.game.*;
import models.Ship;

import java.awt.*;
import java.awt.geom.Point2D;

public class Demo {

    public static String basePath = "assets/sprites/";

    public static void main(String[] args) {
        Game.debugEnabled = true;

        Game game = new Game("Free Shooter");
        GameScene scene = game.getScene();
        Dimension renderSize = game.getRenderSize();

        SpriteGameObject background = new SpriteGameObject("background", basePath + "background.png");
        background.transform.setLocalScale(0.5, 0.5);
        scene.add(background);

        // Create ship
        Ship ship = new Ship("player");
        ship.transform.setPosition(new Point2D.Double(0, renderSize.height * 0.5 - 50));
        ShipController shipController = ship.getComponent(ShipController.class);
        shipController.horizontalEnabled = false;
        shipController.verticalEnabled = false;
        shipController.shootContinues = false;

        RotateTowardsMouse rotator = new RotateTowardsMouse();
        ship.addComponent(rotator);

        AutoGun autoGun = ship.getComponent(AutoGun.class);
        autoGun.mouseDistanceLimited = true;

        scene.add(ship);

        GameObject mousePointer = new GameObject();
        mousePointer.addComponent(new MousePosition());
        scene.add(mousePointer);

        StringGameObject scores = new StringGameObject("得分：0", Color.red);
        scores.transform.setPosition(0, -renderSize.height * 0.5);
        scores.setOrigin(0.5, 0);
        scene.add(scores);
    }
}
